package com.maliu.ui
{
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	import mvc.iface.IToolTip;

	/**
	 * @author maliu
	 */
	public class ToolTip extends Sprite implements IToolTip
	{
		protected var p_title:TextField;
		protected var p_rank:TextField;
		protected var p_preCondition:TextField;
		protected var p_content:TextField;
		
		protected var p_titleFormatter:TextFormat;
		protected var p_rankFormatter:TextFormat;
		protected var p_preConditionFormatter:TextFormat;
		protected var p_contentFormatter:TextFormat;
		
		protected var p_bg:ui_ToolTipBg_Sp;
		
		public function ToolTip()
		{
			this.mouseChildren = false;
			this.mouseEnabled = false;
			initView();
		}
		private function initView():void
		{
			p_bg = new ui_ToolTipBg_Sp();
			this.addChild(p_bg);
			p_bg.width = 250;
			p_bg.height = 110;
			
			//init formatter
			p_titleFormatter = new TextFormat();
			p_titleFormatter.size = 16;
			p_titleFormatter.font = "YouYuan";
			p_titleFormatter.color = 0x0066cc;
			p_titleFormatter.bold = true;
			
			p_rankFormatter = new TextFormat();
			p_rankFormatter.size = 12;
			p_rankFormatter.font = "YouYuan";
			p_rankFormatter.color = 0x00ff33;
			
			p_preConditionFormatter = new TextFormat();
			p_preConditionFormatter.size = 12;
			p_preConditionFormatter.font = "YouYuan";
			p_preConditionFormatter.color = 0xff0000;
			p_preConditionFormatter.leading = 3;
			
			p_contentFormatter = new TextFormat();
			p_contentFormatter.size = 14;
			p_contentFormatter.font = "YouYuan";
			p_contentFormatter.color = 0xffffff;
			p_contentFormatter.leading = 3;
			
			//init TextField
			p_title = new TextField();
			this.addChild(p_title);
			p_title.autoSize = TextFieldAutoSize.LEFT;
			p_title.defaultTextFormat = p_titleFormatter;
			p_title.x = 5;
			p_title.y = 5;
			p_title.text = "轻灵";
			
			p_rank = new TextField();
			this.addChild(p_rank);
			p_rank.autoSize = TextFieldAutoSize.LEFT;
			p_rank.defaultTextFormat = p_rankFormatter;
			p_rank.x = 5;
			p_rank.y = p_title.y +30;
			p_rank.text = "等级：0/4";
			
			p_preCondition = new TextField();
			this.addChild(p_preCondition);
			p_preCondition.autoSize = TextFieldAutoSize.LEFT;
			p_preCondition.defaultTextFormat = p_preConditionFormatter;
			p_preCondition.x = 5;
			p_preCondition.y = p_rank.y +25;
			p_preCondition.text = "需要在通用天赋至少分配4点";
			
			p_content = new TextField();
			this.addChild(p_content);
			p_content.autoSize = TextFieldAutoSize.LEFT;
			p_content.defaultTextFormat = p_contentFormatter;
			p_content.wordWrap = true;
			p_content.x = 5;
			p_content.y = p_preCondition.y + 28;
			p_content.width = p_bg.width - 10;
			p_content.text = "+0.5%移动速度";
			
//			if(p_isDefaultSkin)
//			{
//				p_skin = new DefaultSkin();
//				this.addChild(p_skin);
//			}
//			
//			p_titleFormatter = new TextFormat();
//			p_titleFormatter.bold = true;
//			p_titleFormatter.size = 15;
//			p_contentFormatter = new TextFormat();
//			
//			p_title = new TextField();
//			p_title.autoSize = TextFieldAutoSize.LEFT;
//			p_title.x = 0;
//			p_title.y = 0;
//			this.addChild(p_title);
//			
//			p_content = new TextField();
//			p_content.autoSize = TextFieldAutoSize.LEFT;
//			p_content.wordWrap = true;
//			p_content.width = p_maxWidth;
//			p_content.x = 0;
//			p_content.y = p_title.height+10;
//			this.addChild(p_content);
		}
		//*********************private Method *******************
		//*********************** API ************************
		public function set Title(_title:String):void
		{
			p_title.text = _title;
		}
		public function set Rank(_rank:String):void
		{
			p_rank.text = _rank;
		}
		public function set PreCondition(_preCondition:String):void
		{
			p_preCondition.text = _preCondition;
		}
		public function set Content(_content:String):void
		{
			p_content.text = _content;
			p_bg.height = p_content.y + p_content.height +10;
		}
		public function setContentByList(_contentList:Array):void
		{
			p_title.text = _contentList[0];
			p_rank.text = _contentList[1];
			p_preCondition.text = _contentList[2];
			if(_contentList[2] == "")
			{
				p_content.y = p_preCondition.y;
			}
			else
			{
				p_content.y = p_preCondition.y + p_preCondition.height+10;
			}
			this.Content = _contentList[3];
		}

		public function setContent(_contentList:Array):void
		{
		}
		//*********************** Override Method **********************
//		override public function set width(_value:Number):void
//		{
//			trace("change");
//			super.width = _value;
//		}
	}
}
import flash.display.Sprite;
class DefaultSkin extends Sprite
{
	public function DefaultSkin()
	{
		with(this.graphics)
		{
			beginFill(0x343027);
			drawRect(0, 0, 100, 100);
			endFill();
		}
	}
}
